# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Jason Chu <jason@archlinux.org>

pkgname=lyx
pkgver=2.3.1
_pkgver='2.3.1-2'
pkgrel=1
pkgdesc="An advanced WYSIWYM document processor & LaTeX front-end"
arch=('x86_64')
url="http://www.lyx.org"
depends=('qt5-svg' 'texlive-core' 'python' 'imagemagick' 'enchant' 'boost-libs'
         'libmythes' 'file' 'hicolor-icon-theme')
makedepends=('boost' 'bc')
optdepends=('rcs: built-in version control system'
            'texlive-latexextra: float wrap support'
            'python: support for python scripts')
license=('GPL')
backup=('etc/lyx/lyxrc.dist')
options=('emptydirs')
source=(ftp://ftp.lyx.org/pub/lyx/stable/2.3.x/$pkgname-$_pkgver.tar.xz{,.sig}
        lyxrc.dist)
validpgpkeys=('FE66471B43559707AFDAD955DE7A44FAC7FB382D')  # LyX Release Manager
sha256sums=('f5c9450ba196ed9d49fbc573f65b10d1726d16a62453466957aba2a9f6d66f84'
            'SKIP'
            '7748beb9a821ce06342487e4a60bf4bf632fe2874e187ea54ed654dc6a9ef21e')

prepare() {
  cd $pkgname-$pkgver
  autoreconf -vi
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  export CXXFLAGS="$CXXFLAGS -fpermissive"
  ./configure --prefix=/usr \
    --enable-qt5 --without-included-boost \
    --without-included-mythes
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  # install default config file
  install -Dm644 "${srcdir}/lyxrc.dist" "${pkgdir}/etc/lyx/lyxrc.dist"
  ln -sf /etc/lyx/lyxrc.dist "${pkgdir}/usr/share/lyx/lyxrc.dist"
}
